<template>
  <div
    class="leave-message-item"
    @click="enterToDetailPage"
  >
    <div class="question-box">
      <div>
        <img
          :src="questionImg"
          alt=""
          class="title"
        >
        <span class="quesion">{{info.question}}</span>
        <img
          :src="info.imgs.split(',')[0]"
          alt=""
          class="question-img"
          v-if="info.imgs"
        >
        <!-- <span class="question-img"></span> -->
      </div>
    </div>
    <div class="answer-box" >
      <div v-if="info.answer">
        <img
          :src="answerImg"
          alt=""
          class="title"
        >
        <span class="answer" v-html="info.answerContent" ></span>
        <img class="answer-img">
      </div>
      <span class="time">{{info.createTime}}</span>
    </div>
  </div>
</template>

<script>
import { Cell, CellGroup } from "vant";
import { mapGetters } from "vuex";

export default {
  name: "LeaveMessageItem",
  components: {
    [Cell.name]: Cell,
    [CellGroup.name]: CellGroup,
  },
  props: {
    leaveMessageInfo: {
      type: Object,
      default: () => {},
    },
  },
  watch: {
    leaveMessageInfo: {
      deep: true,
      handler: function (newVal) {
        this.info = newVal;
      },
    },
  },
  data() {
    return {
      message: "",
      takePhotoImg: require("../common/imgs/take-photo.png"),
      questionImg: require("../common/imgs/quesion-icon.png"),
      answerImg: require("../common/imgs/answer-icon.png"),
      disabled: true,
      isShowAnserImg: false,
    };
  },
  created() {
    this.info = this.leaveMessageInfo;
  },
  methods: {
    enterToDetailPage() {
      this.$emit("enterToDetailPage", this.info);
    },
  },
};
</script>

<style lang="less" scoped>
@import "../common/css/common.less";
.leave-message-item {
  padding: 24px;
  background: #ffffff;
  box-sizing: border-box;
  .question-box,
  .answer-box {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    > div {
      display: flex;
      flex-direction: row;
      justify-content: flex-start;
      align-items: flex-start;
      width: 100%;
      .title {
        width: 40px;
        height: 40px;
      }
      .quesion,
      .answer {
        font-size: 28px;
        color: #222222;
        line-height: 40px;
        margin: 0 16px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        flex: 1;
      }
      .question-img {
        width: 120px;
        height: 120px;
        background: #d8d8d8;
        border-radius: 16px;
      }
    }
    .question-box {
      margin-bottom: 24px;
    }
  }
  .answer-box {
    margin-top: 24px;
    .answer-img {
      width: 120px;
      height: 1;
    }
  }
  .time {
    font-size: 22px;
    color: #cccccc;
    line-height: 32px;
    margin-left: 48px;
    margin-top: 20px;
  }
}
</style>
